package io_stream;

import java.io.*;

public class ObjectStream {
    public static void main(String[] args) throws IOException {
        Person person = new Person("张三",20);
        ObjectOutputStream objectOutputStream = new ObjectOutputStream(new FileOutputStream("aaa.bat"));
        objectOutputStream.writeObject(person);
        objectOutputStream.close();

        try {
            ObjectInputStream objectInputStream = new ObjectInputStream(new FileInputStream("aaa.bat"));
            Object o =  objectInputStream.readObject();
            System.out.println(o);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
}
